namespace game {
    export namespace gameData {

        export class Game extends lib.ObjectValue {
            constructor(init:any = null) {
                super();
                this.className = "Game";
				this.$setMember("gold" , new lib.IntValue(null,null,undefined));
				this.goldValue.addListener(lib.Event.CHANGE,function () {if(this.save) this.save("native","gold",this.gold)},this);
				if(this.read) this.gold = this.read("native","gold");
				this.$setMember("diamond" , new lib.IntValue(null,null,undefined));
				this.diamondValue.addListener(lib.Event.CHANGE,function () {if(this.save) this.save("native","diamond",this.diamond)},this);
				if(this.read) this.diamond = this.read("native","diamond");
				if(init) this.value = init;
				this.$addPropertyBinding();

            }
            
            private bindings:Array<lib.Binding>;
            $addPropertyBinding() {
                if(super.$addPropertyBinding) {
                    super.$addPropertyBinding();
                } else {
                    if(!this.bindings) this.bindings = [];
                    for(let i = 0; i < this.bindings.length; i++) this.bindings[i].dispose();
                    this.bindings.length = 0;
                }

            }
            
            checkAllBinding() {
            	this.$addPropertyBinding();
            	for(let key in this.__value) {
            		if(this.__value[key] && this.__value[key].checkAllBinding) this.__value[key].checkAllBinding();
				}
			}
        
			/**
			 * 拥有的金币
			 * @returns {number}
			 */
			get goldValue():lib.Value { return this.__value["gold"]; }

			/**
			 * 拥有的金币
			 * @returns {number}
			 */
			get gold():number {
				return this.__value["gold"].value;
			}

			/**
			 * 拥有的金币
			 * @param {number}
			 */
			set gold(val:number) {
				this.setValue("gold", val);
			}

			/**
			 * 拥有的钻石
			 * @returns {number}
			 */
			get diamondValue():lib.Value { return this.__value["diamond"]; }

			/**
			 * 拥有的钻石
			 * @returns {number}
			 */
			get diamond():number {
				return this.__value["diamond"].value;
			}

			/**
			 * 拥有的钻石
			 * @param {number}
			 */
			set diamond(val:number) {
				this.setValue("diamond", val);
			}


        }
        
        lib.DataManager.getInstance().$addClassDefine(Game,"game.gameData.Game");
        
    }
    
    
}


